from django.conf.urls import url, include
from django.contrib import admin
from rest_framework_jwt.views import obtain_jwt_token
from meiduo_admin.views.login_view import LoginAPIView
from meiduo_admin.views.home_view import *
from meiduo_admin.views.user_view import *
from meiduo_admin.views.sku_view import *
from meiduo_admin.views.spu_view import *
from meiduo_admin.views.spec_view import *
from meiduo_admin.views.spec_option_view import *
from meiduo_admin.views.order_view import *
from meiduo_admin.views.image_view import *
from meiduo_admin.views.prem_view import *
from meiduo_admin.views.group_view import *
from meiduo_admin.views.admin_view import *
from meiduo_admin.views.channel_view import *
from meiduo_admin.views.brand_view import *




from rest_framework.routers import SimpleRouter

urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    # 手动实现登陆视图和序列化器
    # url(r'^authorizations/$', LoginAPIView.as_view()),
    # url(r'^statistical/total_count/$', UserCount.as_view()),
    # url(r'^statistical/day_increment/$', UserDayInc.as_view()),
    # url(r'^statistical/day_active/$', UserDayActive.as_view()),
    # url(r'^statistical/day_orders/$', UserDayOrder.as_view()),
    # url(r'^statistical/month_increment/$', UserMouthInc.as_view()),


    url(r'^statistical/goods_day_views/$', GoodsDayView.as_view()),
    url(r'^users/$', UserView.as_view()),
    # url(r'^skus/$', SKUViewSet.as_view({'get':'list',
    #                                     'post':'retrieve'})),
    # url(r'^skus/categories/$',SKUViewSet.as_view({'get': 'categories',
    #                                               'put':'update',
    #                                                 'delete':'destroy'})),
    url(r'^goods/simple/$',SKU___SkuSpuSimpleView.as_view()),
    # # url(r'^goods/(?P<pk>\d+)/specs/$', SPUSpecSimpleView.as_view()),
    #
    # # sku商品
    url(r'^skus/$', SKU___SkuModelViewSet.as_view({'get':'list', 'post':'create'})),
    url(r'^skus/(?P<pk>\d+)/$', SKU___SkuModelViewSet.as_view({'get':'retrieve',
                                                    'put':'update',
                                                    "delete": "destroy"})),
    #
    url(r'^skus/categories/$', SKU___SkuCategoryView.as_view()),
    # url(r'^goods/simple/$', SPUSimpleView.as_view()),
    # # url(r'^goods/(?P<pk>\d+)/specs/$', SPUSpecSimpleView.as_view()),
    url(r'^goods/(?P<pk>\d+)/specs/$', SKU___SkuSpuSpecView.as_view()),

    # url(r'^skus/$', SKUViewSet.as_view({'get': 'list', 'post': 'create'})),
    # url(r'^skus/(?P<pk>\d+)/$', SKUViewSet.as_view({'get': 'retrieve',
    #                                                 'put': 'update',
    #                                                 "delete": "destroy"})),
    #
    # url(r'^skus/categories/$', SKUViewSet.as_view({'get': 'categories'})),
    # url(r'^goods/simple/$', SPUSimpleView.as_view()),
    # url(r'^goods/(?P<pk>\d+)/specs/$', SKU___SkuSpuSpecView.as_view()),

    # SPU管理
    # 查询获取SPU表数据
    url(r'^goods/$', SPUGoodsView.as_view({'get': 'list',
                                           'post':'create'})),
    url(r'^goods/(?P<pk>\d+)/$', SPUGoodsView.as_view({'delete': 'destroy',
                                                       'put': 'create',
                                                       'get': 'retrieve'
                                                       })),
    # 保存SPU表数据之获取品牌信息
    url(r'^goods/brands/simple/$', SPUBrandView.as_view()),
    # 保存SPU表数据之获取一级分类信息
    url(r'^goods/channel/categories/$', SPUCategory1.as_view()),
    # """保存SPU表数据之获取二三级分类信息"""
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', SPUCategory1.as_view()),


    # spec管理
    # 规格表选项查询,新增
    url(r'^goods/specs/$', SpecView.as_view({'get':'list',
                                             'post':'create'})),
    # 规格表的修改删除
    url(r'^goods/specs/(?P<pk>\d+)/$', SpecView.as_view({'put': 'update',
                                             'delete': 'destroy'})),



    # spec_option管理
    # spec_option查询获取规格选项表数据
    url(r'^specs/options/$', SPEC_OPTION___spec_optionViewSet.as_view({
                                                                        "get":"list",
                                                                        'post':'create',                                                         })),
    # spec_option查询获取品牌信息
    url(r'^goods/specs/simple/$',SPEC_OPTION___spec_option_simple.as_view()),
    # spec_option更新删除规格选项    》》》》不能执行删除功能，模型类的外间关联原因不能执行删除动作
    url(r'^specs/options/(?P<pk>\d+)/$',SPEC_OPTION___spec_optionViewSet.as_view({
                                                                        'delete':'destroy',
                                                                       'put':'update'
                                                                                })),



    # order订单管理

    # order订单管理列表显示
    url(r'orders/$', ORDER___orderViewSet.as_view({'get':'list'})),
    # order订单管理详情展示，显示单条订单的详情
    url(r'orders/(?P<pk>\d+)/$', ORDER___orderViewSet.as_view({'get':'retrieve'})),
    # order订单管理性情展示，修改订单状态
    url(r'orders/(?P<pk>\d+)/status/$', ORDER___orderViewSet.as_view({'put':'update'})),



    # image图片管理

    # 图片管理列表显示
    url(r'^skus/images/$', IMAGE___ImageViewSet.as_view({'get':'list',
                                                         'post':'create',
                                                         'delete':'destroy'})),

    url(r'^skus/simple/$', IMAGE___ImageSkuView.as_view()),




    # 权限管理
    # 权限管理之获取用户权限列表显示
    url(r'^permission/perms/$', PREM___PremView.as_view({'get':'list',
                                                        'post':'create'})),
    # 权限管理获取权限类型列表数据显示
    url(r'^permission/content_types/$', PREM___PremContextTypesView.as_view()),
    # 权限管理之更新获取修改权限表的详情get 单条
    url(r'^permission/perms/(?P<pk>\d+)/$', PREM___PremView.as_view({'get':'retrieve',
                                                                     'put':'update',
                                                                    })),

    # 用户组管理
    # 用户祖数据列表数据显示
    url(r'^permission/groups/$', GROUP___GroupModelViewSet.as_view({'get':'list',
                                                                    'post':'create',
                                                                    })),
    # 获取用户权限表数据
    url(r'^permission/simple/$', GROUP___GroupPermViewSet.as_view()),
    # 修改用户权限表，提交数据
    url(r'^permission/groups/(?P<pk>\d+)/$', GROUP___GroupModelViewSet.as_view({'put':'update',
                                                                                'delete': 'destroy',
                                                                                'get':'retrieve'
                                                                                })),



    # 管理员管理
    # 管理员列表展示数据
    url(r'^permission/admins/$', ADMIN___AdminModelViewSet.as_view({'get':'list',
                                                                    'post':'create',
                                                                    })),
    # 管理元分组信息列表展示
    url(r'^permission/groups/simple/$', ADMIN___AdminSimpleView.as_view()),

    url(r'^permission/admins/(?P<pk>\d+)/$', ADMIN___AdminModelViewSet.as_view({'get':'retrieve',
                                                                                'put':'update',
                                                                               'delete': 'destroy',})),

    # 频道管理
    # 获得所有频道信息
    url(r'^goods/channels/$', CHANNEL___ChannelViewSet.as_view({'get':'list',
                                                                'post':'create'})),
    # 获得但以频道信息
    # url(r'^goods/channels/(?P<pk>\d+)/$', CHANNEL___ChannelView.as_view()),
    # 更新修改频道信息
    url(r'^goods/channels/(?P<pk>\d+)/$', CHANNEL___ChannelViewSet.as_view({'put':'update',
                                                                            'delete':'destroy',
                                                                            'get':'retrieve',
                                                                            })),
    # 获得频道所有分组
    url(r'^goods/channel_types/$', CHANNEL___ChannelTypesVeiw.as_view()),
    url(r'^goods/categories/$', CHANNEL___CategoryView.as_view()),



    # 品牌管理
    url(r'^goods/brands/$', BRAND___BrandModelViewSet.as_view({'get':'list',
                                                               'post':'create'})),
    url(r'^goods/brands/(?P<pk>\d+)/$', BRAND___BrandModelViewSet.as_view({'delete':'destroy'}))
]

router = SimpleRouter()
router.register(prefix='statistical',viewset=HomeViewSet,base_name='home')
# router.register(prefix='goods/specs', viewset=SpecViewSet, base_name='specs')
# router.register(prefix='specs/options', viewset=SPEC_OPTION___spec_optionViewSet, base_name='options')
urlpatterns += router.urls